import { Component, Prefab, _decorator } from "cc";
import { createECS } from "../../app-core/ecs/ECSWorld";
import { InputSystem } from "./systems/InputSystem";
import { MovableSystem } from "./systems/MovableSystem";
import { NpcSystem } from "./systems/NpcSystem";

const { ccclass, property } = _decorator;

@ccclass('BattleLogic')
export class BattleLogic extends Component {

    @property(Prefab)
    npcPrefab: Prefab = null;

    private ecs = createECS();

    onLoad(): void {
        this.ecs.systems.add(new InputSystem(this.node));
        this.ecs.systems.add(new NpcSystem(this.node, this.npcPrefab));
        this.ecs.systems.add(new MovableSystem());


    }

    start(): void {
        this.ecs.start();
    }

    stop() {
        this.ecs.stop();
    }

    update(dt) {
        this.ecs.update(dt);
    }
}